<div class="waypoint container">
    <div class="row">
        <div class="col-md-12">
            <h2 class="page-title">Empresas</h2>
        </div>
        
        <div class="col-md-12">
            <ol class="breadcrumb">
                <li><a href="<?php echo $this->url(array('controller' => 'admin', 'action' => 'index'))?>">Admin</a></li>
                <li>Empresas</li>
            </ol>
        </div>
        

        <div class="col-md-12">
            <div class="alert alert-info" style="width: 100%; text-align: center">
                Existem <?php echo count($this->companies); ?> empresas cadastradas.
            </div>
            <br /><br />
            
            <table class="table">
                <thead>
                  <tr>
                    <th>ID</th>
                    <th>Logo</th>
                    <th>Nome</th>
                    <th>Categoria</th>
                    <th>Status</th>
                    <th>Registro</th>
                    <th>Avaliações</th>
                    <th>Ações</th>
                  </tr>
                </thead>
                <tbody>
                  <?php foreach($this->companies AS $company) { ?>
                    <tr class="<?php if($company['deleted'] == 1) echo 'danger'; ?>">
                      <td><?php echo $company['id']; ?></td> 
                      <?php 
                          if ($company['logo'] == '') {
                            $imgLogo = '/img/default-logo.jpg';
                          }else {
                            $imgLogo = $company['logo'];
                          }
                      ?> 
                      <td><img class="img-thumbnail" width="50" height="50" src="<?php echo $this->baseUrl().$imgLogo;  ?>" /></td>  
                      <td><a href="<?php echo $this->url(array('controller' => 'evaluation', 'action' => 'detalhes', 'company' => $company['friendly_name'])); ?>">
                          <?php echo $company['name']; ?>
                      </a></td>
                      <td><?php echo $company['category']; ?></td>
                      <td>
                      <?php if($company['active'] == 1) { ?>
                          <span class="btn btn-success btn-small disabled">Ativo</span>
                      <?php } else { ?>
                          <span class="btn btn-warning btn-small disabled">Aguar. Moderação</span>
                      <?php } ?>
                      </td>
                      <td><?php echo date("d/m/Y H:i", strtotime($company['created_at'])); ?></td>
                      <td><span class="badge"><?php echo $company['evaluations']; ?></span></td>
                      <td>
                          <?php if($company['deleted'] == 0) { ?>
                            <a href="<?php echo $this->url(array('controller' => 'admin', 'action' => 'remover-empresas', 'company' => $company['id']))?>" class="btn btn-small btn-danger"><span class="fa fa-ban"></span></a>
                          <?php } else { ?>
                            <a href="<?php echo $this->url(array('controller' => 'admin', 'action' => 'remover-empresas', 'company' => $company['id']))?>" class="btn btn-small btn-warning"><span class="fa fa-undo"></span></a>
                          <?php } ?>
                          <a href="<?php echo $this->url(array('controller' => 'admin', 'action' => 'editar-empresas', 'company' => $company['id']))?>" class="btn btn-small btn-primary"><span class="fa fa-edit"></span></a>
                      </td>
                    </tr>
                  <?php } ?>
                </tbody>
              </table>
            <br /><br /><br /><br />
        </div><!-- end .col-md-12 -->

    </div><!-- end .row -->
</div><!-- end section -->
